<template>
  <div id="login">
    <div class="header">
      <a href="/index"
        ><img src="http://1.117.75.96:8080/login/logo.png" alt=""
      /></a>
    </div>
    <div class="containers">
      <div class="leftbox">
        <ul>
          <li>
            <img src="http://1.117.75.96:8080/login/login_big.jpg" alt="" />
          </li>
        </ul>
      </div>
      <div class="rightbox">
        <form action="" class="login">
          <h2>登录</h2>
          <p class="part">
            <input
              type="text"
              name="username"
              v-model="username"
              placeholder="用户名/手机号"
            />
          </p>
          <p class="part">
            <input
              type="password"
              name="password"
              v-model="password"
              placeholder="密码"
            />
          </p>
          <div class="checked">
            <input type="checkbox" name="rule" v-model="checked" />
            <p>
              我已阅读并同意<span>ASUS条款</span>&<span>隐私政策</span>&<span>隐私说明</span>&<span
                >华硕会员服务隐私说明</span
              >
            </p>
          </div>
          <div class="btn" @click="log">登录</div>
          <div class="more">
            <a href="#" class="forget">忘记密码</a>
            <router-link to="/reg" class="reg">注册账号</router-link>
          </div>
          <div class="other">
            <p>其他登录方式</p>
            <img src="http://1.117.75.96:8080/login/weixin.png" alt="" />
          </div>

          <div class="rightTop">
            <img src="http://1.117.75.96:8080/login/code1.png" alt="" />
          </div>
        </form>
        <ul class="codeBox">
          <li>
            <img
              src="http://1.117.75.96:8080/login/14555054505248.png"
              alt=""
            />
          </li>
          <li>
            <img
              src="http://1.117.75.96:8080/login/17321648564953.png"
              alt=""
            />
          </li>
        </ul>
      </div>
    </div>
    <div class="load" style="display: none">
      <img src="http://1.117.75.96:8080/login/loading.gif" alt="" />
    </div>
  </div>
</template>

<script>
import { mapActions } from 'vuex'
export default {
  data() {
    return {
      username: '',
      password: '',
      checked: false
    }
  },
  methods: {
    ...mapActions(['handleLogin']),
    async log() {
      if (!this.checked) {
        this.$layer.msg('请先同意协议')
        return
      }
      let params = { password: this.password, username: this.username }
      try {
        var flg = await this.handleLogin(params)
      } catch (error) {}
      if (flg) {
        this.$layer.alert('登录成功', (id) => {
          this.$router.push({ name: 'Home' })
          this.$layer.close(id)
        })
      } else {
        this.$layer.msg('账号或者密码错误,请重试')
      }
    }
  }
}
</script>

<style lang="less" scoped>
.header {
  width: 1413px;
  padding: 0 125px;
  margin: 0 auto 44px;
  box-sizing: border-box;

  a {
    display: inline-block;

    img {
      width: 519px;
      height: 84px;
    }
  }
}

.containers {
  width: 1413px;
  margin: auto;
  font-size: 0;
  text-align: center;

  .leftbox {
    display: inline-block;
    vertical-align: middle;
    margin-left: 125px;
    margin-right: 70px;
    width: 510px;
    height: 566px;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .rightbox {
    display: inline-block;
    vertical-align: middle;

    .login {
      position: relative;
      display: inline-block;
      padding: 0 46px;
      width: 478px;
      text-align: left;
      background: #fff;
      border-radius: 16px;
      box-shadow: 0px 0px 24px 0px rgb(0 0 0 / 4%);

      h2 {
        padding-top: 89px;
        font-size: 34px;
        line-height: 46px;
        font-family: HarmonyOS Sans SC Medium;
        font-weight: 600;
        color: #000;
        margin-bottom: 34px;
      }

      .part {
        input {
          display: block;
          padding: 0 20px;
          width: 100%;
          height: 64px;
          font-size: 22px;
          background: #f7f7f7;
          border-radius: 12px;
          border: none;
          outline: none;
          box-shadow: none;
          margin-bottom: 16px;
          box-sizing: border-box;
        }
      }

      .checked {
        display: flex;
        padding-top: 8px;
        height: 21px;

        p {
          display: inline-block;
          vertical-align: top;
          line-height: 21px;
          font-size: 16px;
          color: #6a6a6a;
          margin-left: 4px;

          span {
            display: inline-block;
            vertical-align: top;
            font-size: 16px;
            color: #000;
            text-decoration: none;
          }
        }
      }

      .btn {
        width: 100%;
        height: 64px;
        line-height: 64px;
        font-size: 24px;
        color: #fff;
        font-family: HarmonyOS Sans SC Medium;
        font-weight: 600;
        text-align: center;
        background: #1f7efe;
        border-radius: 12px;
        margin-top: 24px;
        cursor: pointer;
      }

      .more {
        margin-top: 8px;
        width: 100%;
        overflow: hidden;

        a {
          font-size: 22px;
          color: #535353;
          font-family: HarmonyOS Sans SC Medium;
          font-weight: 600;
          line-height: 30px;
          cursor: pointer;
        }

        .reg {
          color: #1f7efe;
          float: right;
        }

        .forget {
          float: left;
        }
      }

      .other {
        padding: 80px 0 40px;
        width: 100%;
        text-align: center;
        font-size: 24px;
        line-height: 32px;
        font-weight: 600;
        color: #c3c4c4;

        img {
          width: 56px;
          height: 56px;
          margin: 16px auto 0;
          cursor: pointer;
        }
      }

      .rightTop {
        position: absolute;
        right: 0;
        top: 0;
        width: 136px;
        height: 136px;
        z-index: 1;
        cursor: pointer;

        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }

  .codeBox {
    margin-left: 40px;
    padding-top: 181px;
    display: inline-block;
    vertical-align: top;

    img {
      width: 96px;
      height: 96px;
      margin: 0 auto 2px;
    }
  }
}
</style>
